Memory and method for checking reading errors thereof

ABSTRACT

A method for checking reading errors of a memory includes receiving a first data fragment and accordingly generating a first ECC and a first count index; writing the first data fragment, the first ECC and the first count index into a memory; reading the first data fragment from the memory as a second data fragment, generating a second ECC and second count index according to the second data fragment; determining whether the first count index and second count index are equal; determining whether the first ECC and the second ECC are equal; and outputting the second data fragment when the first count index is equal to the second count index and the first ECC is equal to the second ECC.

This application claims the benefit of Taiwan application Serial No.95141200, filed Nov. 7, 2006, the subject matter of which isincorporated herein by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The invention relates in general to a memory and method for checkingreading errors thereof, and more particularly to a memory whose accuracycan be increased and memory space can be reduced in a reading operation,and method for checking reading errors thereof.

2. Description of the Related Art

A flash memory is one of the various applications of non-volatile memorytechnology today. The flash memory can be used for reading and writingdata and the data stored in the flash memory can be maintained withoutelectricity power, and thus it can be applied to various kinds of datastorage. However, it is an essential subject in memory design to ensurecompleteness of the data stored in the memory. Traditionally, an errorcorrection code (ECC) is used to meet the requirement. The errorcorrection code is used to detect and correct a bit error in aconventional method for checking data completeness.

Referring to FIG. 1, a flow chart of a conventional method for checkingmemory reading errors is shown. First, in step 100, receive at least adata fragment. Following that, in step 110, generate an error correctioncode according to the at least data fragment through an ECC algorithm.The error correction code has a size corresponding to the at least datafragment. For example, when the at least a data fragment has a size of256 bytes, the error correction code has a size of 22 bits due torequirement for calculating error correction parity bits and theircomplements.

Next, in step 120, write the at least data fragment and error correctioncode into the memory. Then, in step 130, read the at least a datafragment from the memory to be at least a reading data fragment.Afterward, in step 140, generate a new error correction code accordingto the at least a reading data fragment through an ECC algorithm. Instep 150, determine whether the at least a reading data fragment is thesame as the at least a data fragment according to the error correctioncode and new error correction code. In the step 150, substantially, anexclusive or operation is performed on the error correction code and newerror correction code according to the ECC algorithm. If the result is0, the at least a reading data fragment is the same as the at least adata fragment.

If the at leas a reading data fragment is the same as the at least adata fragment, in step 160, the memory determines the reading operationis correct and outputs the at least a reading data fragment. If the atleast a reading data fragment is different from the at least a datafragment, in step 170, correct the at least a reading data fragment tobe the at least a data fragment by using the new error correction codeand output the at least a reading data fragment if the memory determinesthe reading operation has a 1 bit error.

In the above conventional method for checking memory reading errors, theECC algorithm can detect and correct 1 bit error. However, it can onlydetect more than one bit error, such as 2, 3 or 4 bit errors, but cannot correct these errors. It can only inform the memory that a number ofbit errors are generated.

SUMMARY OF THE INVENTION

The invention is directed to a memory and method for checking readingerrors thereof. By using a count index together with the errorcorrection code, the memory can detect and correct a number of biterrors to improve correctness of memory reading operation and savememory space.

According to a first aspect of the present invention, a method forchecking reading errors of a memory is provided. The method comprisesreceiving a first data fragment; generating a first ECC and a firstcount index according to the first data fragment, wherein the firstcount index is corresponding to a quantity of one kind of binary valuein the first data fragment; writing the first data fragment, the firsterror correction code and the first count index into a memory; readingthe first data fragment from the memory as a second data fragment;generating a second error correction code and a second count indexaccording to the second data fragment; determining whether the firstcount index and the second count index are equal; determine whether thefirst error correction code and the second error correction code areequal; and outputting the second data fragment when the first countindex and the second count index are equal, and the first errorcorrection code and the second error correction code are equal.

According to a second aspect of the present invention, a memory isprovided. The memory comprises a memory-cell array, an error correctioncircuit and an n-bit counter. The memory-cell array is for receiving andstoring a first data fragment, and reading the first data fragment fromthe memory-cell array to be a second data fragment. The error correctioncircuit is for generating a first ECC according to the first datafragment and generating a second ECC according to the second datafragment. The n-bit counter is for generating a first count index and asecond count index, wherein the first count index and the second countindex are respectively corresponding to a quantity of one kind of binaryvalue occurred in the first data fragment and a quantity of one kind ofbinary value occurred in the second data fragment, and n is a positiveinteger. The memory determines whether the second data fragment is equalto the first data fragment according to the first count index, thesecond count index, the first error correction code and the second errorcorrection code. When the second data fragment has y bit errors ascompared to the first data fragment, the memory corrects the second datafragment to be the first data fragment and outputs the second datafragment, and y is a positive integer smaller or equal to n.

The invention will become apparent from the following detaileddescription of the preferred but non-limiting embodiments. The followingdescription is made with reference to the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flow chart of a conventional method for checking memoryreading errors.

FIG. 2 is a flow chart of a method for checking memory reading errorsaccording to a preferred embodiment of the invention.

FIG. 3 is a schematic diagram of a count index in the method forchecking memory reading errors according to the preferred embodiment ofthe invention.

FIG. 4 is a distribution diagram of threshold voltages of the memorycells in the memory according to the preferred embodiment of theinvention.

FIG. 5 is a block diagram of a memory according to the preferredembodiment of the invention.

FIG. 6 is a circuit diagram of a 3-bit counter according to thepreferred embodiment of the invention.

DETAILED DESCRIPTION OF THE INVENTION

The invention is directed to a memory and method for checking readingerrors thereof. By using a count index generated by an extra countertogether with the error correction code generated by the ECC algorithm,the memory can detect and correct a number of bit errors to improvecorrectness of memory reading operation and save memory space.

Referring to FIG. 2, a flow chart of a method for checking memoryreading errors according to a preferred embodiment of the invention isshown. The method is applied to a memory which can be a non-volatilememory, such as a single-level-cell (SLC) flash memory or amulti-level-cell (MLC) flash memory. First, in step 200, receive a firstdata fragment, such as, formed by 1 and 0.

Then, in step 210, generate a first error correction code and a firstcount index according to the first data fragment. The first errorcorrection code is generated by an ECC algorithm and has a sizecorresponding to the first data fragment. Owing that the invention onlyneeds to calculate the size of error correction parity bits and theircomplements, when the first data fragment has a size of 256 bytes forinstance, the first error correction code has a size of 11 bits. Thefirst count index is corresponding to a quantity of one kind of binaryvalue, such as a number of 1 occurred in the first data fragment and hasa size of n bits, wherein n is a positive integer. Therefore, the methodfor checking memory reading errors disclosed in the embodiment candetermine n bit errors in maximum.

The first data fragment is exemplified to have 256 bytes and the firstcount index is exemplified to have 3 bits for illustration, but theinvention is not limited thereto. Referring to FIG. 3, a schematicdiagram of a count index in the method for checking memory readingerrors according to the preferred embodiment of the invention is shown.If the first data fragment has 68 1s and 1980 0s, the first count indexstarts from H(000), counts a number of 1 occurred in the first datafragment by following an order of A to H, and stops at a position ofD(100).

Following that, in step 220, write the first data fragment, first errorcorrection code and first count index into the memory. Next, in step230, read the first data fragment from the memory to be a second datafragment which is also formed by 1 and 0 for instance. Then, in step240, generate a second error correction code and a second count indexaccording to the second data fragment. The second error correction codeis generated by an ECC algorithm and the second count index, which has asize of n bits, is corresponding to a quantity of one kind of binaryvalue, such as, a number of 1 occurred in the second data fragment.

Afterward, in step 250, determine whether the first count index and thesecond count index are equal, that is, determine whether the number of 1in the first data fragment is equal to the number of 1 in the seconddata fragment. If the first count index is the same as the second countindex, the second count index also stops in the position of D(100) andthen in step 260, determine whether the first ECC code and the secondECC code are equal. In the step 260, substantially, an exclusive oroperation is performed on the first error correction code and seconderror correction code according to the ECC algorithm. If the result is0, the first ECC code and the second ECC code are equal.

If the first ECC code is the same as the second ECC code, in step 270,the memory determines the reading operation is correct and outputs thefirst data fragment to the user. If the first ECC code is not equal tothe second ECC code, in step 290, it is determined that there is ECCerror. Besides, when the first count index is not equal to the secondcount index, in step 280, determine if the first count index differsfrom the second count index by 1. If the first count index differs fromthe second count index by 1, for example, the first count index islocated at the position of D(100), and the second count index (readpoint) is located at a position of C(011) or E(101), in step 281, updateSRAM by ECC algorithm to directly correct the second data fragment to bethe first data fragment and go back to the step 270 to output the firstdata fragment to the user. When the first count index differs from thesecond count index by 1, the second data fragment has 1 bit error ascompared to the first data fragment.

In the step 280, if the first count index does not differ from thesecond count index by 1, in step 282, determine if the second countindex is smaller than the first count index by 2 or 3, that is, if thefirst count index is located at the position of D(100), the second countindex (read point) is located in a position of A(001), or B(010). Ifyes, in step 283, decrease a reference current of the memory in thereading operation and return to the step 230 in which the memory readsthe first data fragment to be a second data fragment. If no, in step284, determine if the second count index is larger than the first countindex by 2 or 3, that is, if the first count index is located at theposition of D(100), the second count index (read point) is located in aposition of F(110) or G(111). If yes, increase a reference current ofthe memory in the reading operation and return to the step 230. If no,the second count index is at H(000) if the first count index is atD(100) and it is determined that there are more than 3 bit errors instep 290. When the first count index differs from the second count indexby m, the second data fragment has m bit errors as compared to the firstdata fragment, wherein m is a positive integer larger than 1 and smallerthan or equal to n. The number n is 3 and m is 2 or 3 in the embodiment.

Referring to FIG. 4, a distribution diagram of threshold voltages of thememory cells in the memory according to the preferred embodiment of theinvention is shown. The memory of FIG. 4 is exemplified to be a MLCflash memory for illustration, but the invention is not limited thereto.When a drain current of the memory cell is larger than a referencecurrent outputted by a reference unit, the threshold voltage of thememory cell is determined to be smaller than a reference thresholdvoltage VTref, that is, the data fragment stored in the memory cellis 1. When the drain current of the memory cell is smaller than thereference voltage outputted by the reference unit, the threshold voltageof the memory cell is determined to be larger than the referencethreshold voltage VTref, that is, the data fragment stored in the memorycell is 0.

Therefore, in step 250, when the first count index is larger than thesecond count index by m, that is, if the first count index is located atthe position of D(100), the second count index is located in a positionof A(001) or B(010), which represents 2 or 3 1s are neglected inreading. Then, in the operation interval of the memory, the referencethreshold voltage is shifted to the right, that is, the referencecurrent is reduced and the step 230 is repeated to perform a readingoperation. When the first count index is smaller than the second countindex by m, that is, if the first count index is located in the positionof D(100), the second count index is located in a position of F(110) orG(111), which represents 2 or 3 extra 1s are read. Therefore, in theoperation interval of the memory, the reference threshold voltage VTrefis shifted to the left, that is, the reference current is increased andthe step 230 is repeated to perform the reading operation.

Referring to FIG. 5, a block diagram of a memory according to thepreferred embodiment of the invention is shown. A memory 500 is anon-volatile memory, such as a SLC flash memory or a MLC flash memoryand includes a memory-cell array 510, an error correction circuit 520and an n-bit counter 530. The memory-cell array 510 is for receiving andstoring a first data fragment Data, such as formed by 1 and 0, and thememory 500 reads the first data fragment Data from the memory-cell array510 to be a second data fragment DataR, which is formed by 1 and 0 forinstance.

The error correction circuit 520 is for generating a first errorcorrection code according to the first data fragment Data and generatinga second error correction code according to the first reading datafragment. The n-bit counter 530 is for generating a first count indexand second count index, which are respectively corresponding to aquantity of one kind of binary value, such as a number of 1 occurred inthe first data fragment Data and in the second data fragment DataR,wherein n is a positive integer.

The memory determines whether the second fragment DataR is the same asthe first data fragment Data by using the first count index, secondcount index, first error correction code and second error correctioncode. When the second data fragment DataR has y bit errors as comparedto the first data fragment Data, the memory corrects the second datafragment DataR to be the first data fragment Data and outputs the seconddata fragment, wherein y is a positive integer smaller than or equal ton.

The invention is not limited to the above n-bit counter circuit. Infact, any other counting circuit, such as a circuit with n triggerflip-flops (T-FF), can be applied to the n-bit counter circuit of thememory 500. Referring to FIG. 6, a circuit diagram of a 3-bit counteraccording to the preferred embodiment of the invention is shown. A 3-bitcounter 600 uses 3 T-FFs to perform a counting operation according to aclock signal CLK of the memory 500 and the data fragment Data. Besides,the method for checking reading errors of the memory 500 has beendescribed in detailed in the method for checking memory reading errorsdisclosed by the above embodiment of the invention. Therefore, anydetail is not necessary to be given here again.

In the memory and method for checking reading errors thereof disclosedby the above embodiment of the invention, by using the count indexgenerated by an extra counter together with the error correction codegenerated by an ECC algorithm, the memory can detect and correct anumber of bit errors to improve the correctness of memory readingoperation. Moreover, the invention needs only to count one of the errorcorrection parity bits and the corresponding complement. Therefore, whenthe data fragment has a size of 256 bytes for instance, the errorcorrection code has a size of 11 bits. If a 3-bit counter is applied,the error correction code and count index totally need to be 14 bits.Therefore, the method of the invention can save much memory space ascompared to the prior-art method.

While the invention has been described by way of example and in terms ofa preferred embodiment, it is to be understood that the invention is notlimited thereto. On the contrary, it is intended to cover variousmodifications and similar arrangements and procedures, and the scope ofthe appended claims therefore should be accorded the broadestinterpretation so as to encompass all such modifications and similararrangements and procedures.

1. A method for checking reading errors of a memory, comprising:receiving a first data fragment; generating a first error correctioncode (ECC) and a first count index according to the first data fragment,wherein the first count index is corresponding to a quantity of one kindof binary value in the first data fragment; writing the first datafragment, the first error correction code and the first count index intoa memory; reading the first data fragment from the memory as a seconddata fragment; generating a second error correction code and a secondcount index according to the second data fragment; determining whetherthe first count index and the second count index are equal; determinewhether the first error correction code and the second error correctioncode are equal; and outputting the second data fragment when the firstcount index and the second count index are equal, and the first errorcorrection code and the second error correction code are equal.
 2. Themethod according to claim 1, wherein the binary value is
 1. 3. Themethod according to claim 1, wherein the binary value is
 0. 4. Themethod according to claim 1, wherein the memory is a non-volatilememory.
 5. The method according to claim 2, wherein the memory is asingle-level-cell (SLC) flash memory.
 6. The method according to claim2, wherein the memory is a multi-level-cell (MLC) flash memory.
 7. Themethod according to claim 1, wherein the first count index is obtainedby using an n-bit counter, and n is a positive integer.
 8. The methodaccording to claim 7, wherein the method for checking reading errors ofa memory can determine the second data fragment has n bit errors at mostas compared to the first data fragment.
 9. The method according to claim7, further comprising: if the first count index is not equal to thesecond count index and the first count index differs from the secondcount index by 1, correcting the second data fragment to be the firstdata fragment by using the second correction code, and outputting thesecond data fragment.
 10. The method according to claim 9, wherein ifthe first count index differs from the second count index by 1, thesecond data fragment has 1 bit error as compared to the first datafragment.
 11. The method according to claim 7, further comprising: ifthe first count index is not equal to the second count index and thefirst count index differs from the second count index by x, correctingthe second data fragment to be the first data fragment by using thesecond correction code, and outputting the second data fragment, whereinx is a positive integer and less than a positive integer m.
 12. Themethod according to claim 11, wherein if the first count index differsfrom the second count index by x, the second data fragment has x bitserror as compared to the first data fragment.
 13. The method accordingto claim 7, further comprising: if the first count index is not equal tothe second count index and the first count index differs from the secondcount index by m, changing a reference current of the memory in thereading operation; and reading again the first data fragment from thememory to be the second data fragment; wherein m is a positive integerlarger than 1 and smaller than or equal to n.
 14. The method accordingto claim 13, wherein if the first count index is larger than the secondcount index by m, reducing the reference current and if the first countindex is smaller than the second count index by m, increasing thereference current.
 15. The method according to claim 13, wherein if thefirst count index differs from the second count index by m, the seconddata fragment has m bit errors as compared to the first data fragment.16. A memory, comprising: a memory-cell array, for receiving and storinga first data fragment, reading the first data fragment from thememory-cell array to be a second data fragment; an error correctioncircuit, for generating a first error correction code (ECC) according tothe first data fragment and generating a second error correction codeaccording to the second data fragment; and an n-bit counter, forgenerating a first count index and a second count index, wherein thefirst count index and the second count index are respectivelycorresponding to a quantity of one kind of binary value occurred in thefirst data fragment and a quantity of one kind of binary value occurredin the second data fragment, and n is a positive integer; wherein thememory determines whether the second data fragment is equal to the firstdata fragment according to the first count index, the second countindex, the first error correction code and the second error correctioncode; wherein when the second data fragment has y bit errors as comparedto the first data fragment, the memory corrects the second data fragmentto be the first data fragment and outputs the second data fragment, andy is a positive integer smaller or equal to n.
 17. The memory accordingto claim 16, is a non-volatile memory.
 18. The memory according to claim17, is a single-level-cell flash memory.
 19. The memory according toclaim 17, a multi-level-cell flash memory.
 20. The memory according toclaim 16, wherein if the first count index differs from the second countindex by 1, the memory corrects the second data fragment to be the firstdata fragment by using the second correction code, and outputs thesecond data fragment.
 21. The memory according to claim 20, wherein ifthe first count index differs from the second count index by 1, thesecond data fragment has 1 bit error as compared to the first datafragment.
 22. The memory according to claim 16, wherein if the firstcount index differs from the second count index by m, the memory changesa reference current of the reading operation to read again the firstdata fragment from the memory to be the second data fragment, wherein mis a positive integer larger than 1 and smaller than or equal to n. 23.The memory according to claim 22, wherein if the first count index islarger than the second count index by m, the memory reduces thereference current and if the first count index is smaller than thesecond count index by m, the memory increases the reference current. 24.The memory according to claim 22, wherein if the first count indexdiffers from the second count index by m, the second data fragment has mbit errors as compared to the first data fragment.
 25. The methodaccording to claim 16, further comprising: if the first count index isnot equal to the second count index and the first count index differsfrom the second count index by x, correcting the second data fragment tobe the first data fragment by using the second correction code, andoutputting the second data fragment, wherein x is a positive integer andless than m.
 26. The method according to claim 25, wherein if the firstcount index differs from the second count index by x, the second datafragment has x bits error as compared to the first data fragment